<?php

namespace App\Repository\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

/**
 * Class Report.
 *
 * @package namespace App\Repository\Models;
 */
class Report extends Model implements Transformable
{
    use TransformableTrait;
    use SoftDeletes;
    protected $table = 'report';
    protected $appends = [ 'status_name'];

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['user_id','user_name','product_name','shop_name','report_type_id','report_type','status','explain','created_at','updated_at'];
    //举报状态
    public static $report_status_map = [
        0 => '未处理',
        1 => '已处理',
        2 => '无效',
    ];
    public function getStatusNameAttribute()
    {
        return array_get(self::$report_status_map, $this->attributes['status']) ?: '-';
    }
    public function reportType()
    {
        return $this->hasOne(ReportType::class, 'id', 'report_type_id');
    }

}
